package com.alex;

import com.alex.mapper.UserMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

@SpringBootApplication
@EnableTransactionManagement
@MapperScan("com.alex.mapper")
public class MPGApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(MPGApplication.class, args);

        for (String beanDefinitionName : ctx.getBeanDefinitionNames()) {
            System.out.println(beanDefinitionName);
        }
        UserMapper userMapper = ctx.getBean("userMapper", UserMapper.class);
        System.out.println(userMapper);
        userMapper.selectList(null).forEach(System.out::println);
        System.out.println(ctx.getBean("dataSource", DataSource.class));
    }
}
